package ano.it.service.impl;

import ano.it.dao.PermissionDao;
import ano.it.entity.PageResult;
import ano.it.entity.QueryPageBean;
import ano.it.pojo.GreenHouse;
import ano.it.pojo.Permission;
import ano.it.service.MenuService;
import ano.it.service.PermissionService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service(interfaceClass = PermissionService.class)
@Transactional
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionDao permissionDao;
    @Override
    public List<Permission> findAll() {
        return permissionDao.findAll();
    }

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {

        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());

        Page<Permission> page=permissionDao.selectByCondition(queryPageBean.getQueryString());
        long total=page.getTotal();
        List<Permission> rows=page.getResult();
        return new PageResult(total,rows);
    }

    @Override
    public void add(Permission permission) {
        permissionDao.add(permission);
    }
}
